<template>
  <header class="header">
    <div class="logo">小花在线</div>
    <div class="avatar-container" @click="goToProfile">
      <img class="avatar" :src="avatarUrl" alt="Profile Avatar" />
    </div>
  </header>
</template>

<script setup>
import { ref, onMounted } from 'vue';
import { useRouter } from 'vue-router';

const avatarUrl = ref('https://img2.baidu.com/it/u=2925226694,390810694&fm=253&fmt=auto?w=500&h=500');

const router = useRouter();

const goToProfile = () => {
  // 假设用户点击头像后跳转到个人资料页面
  router.push('/profile');
};
</script>

<style lang="scss" scoped>
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background-color: #333;
  color: #fff;

  .logo {
    font-size: 1.2em;
    font-weight: bold;
  }

  .avatar-container {
    position: relative;
    cursor: pointer;

    .avatar {
      width: 50px;
      height: 50px;
      border-radius: 50%;
      object-fit: cover;
    }
  }

  @media (max-width: 768px) {
    padding: 8px 15px;

    .logo {
      font-size: 1em;
    }

    .avatar-container .avatar {
      width: 40px;
      height: 40px;
    }
  }

  @media (max-width: 480px) {
    padding: 6px 10px;

    .avatar-container .avatar {
      width: 35px;
      height: 35px;
    }
  }
}
</style>